<?php

$connect = mysqli_connect('localhost','root','','ajax');

if (!$connect)
{
    die('Error: connection failed');
}

require_once 'connect.php';
$title = $_POST['title'];
$content = $_POST['content'];


$msql = "INSERT INTO `post` (`id`, `title`, `content`) VALUES (NULL, '$title', '$content')";
mysqli_query($connect, $msql);


$posting_contents = mysqli_query($connect, "SELECT * FROM `post`");
$fetch_contents = mysqli_fetch_assoc($posting_contents);
$_SESSION['fetch_contents'] = [
        "id" => $fetch_contents['id'],
    "title" => $fetch_contents['title'],
    "content" => $fetch_contents['content'],
];
?>



<!doctype html>
<html lang="en">
<head>
    <link>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Результат пост/запись</title>
</head>
<body>
<div>
    <form>

        <p><h3 style="margin: 10px 0;"><?= $_SESSION['fetch_contents']['title'] ?></h3></p>
<p><a style="margin: 10px 0;"><?= $_SESSION['fetch_contents']['content'] ?></a></p>

</form>
</div>
</body>
</html>





